<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return redirect('/blog');
});

Route::get('/blog', 'BlogController@index')->name('blog.home');
Route::get('/blog/{slug}', 'BlogController@showPost')->name('blog.detail');

//后台路由
Route::get('/admin', function () {
    return redirect('/admin/post');
});
Route::middleware('auth')->prefix('admin')->namespace('Admin')->group(function () {
    Route::resource('/post', 'PostController');
    Route::resource('/tag', 'TagController', ['except' => 'show']);

    //文件上传管理功能
    Route::prefix('upload')->group(function () {
        Route::get('/', 'UploadController@index');
        Route::post('/file', 'UploadController@uploadFile');
        Route::delete('/file', 'UploadController@deleteFile');
        Route::post('/folder', 'UploadController@createFolder');
        Route::delete('/folder', 'UploadController@deleteFolder');
    });
});

//登录退出
Route::get('/login', 'Auth\LoginController@showLoginForm')->name('login');
Route::post('/login', 'Auth\LoginController@login');
Route::get('/logout', 'Auth\LoginController@logout')->name('logout');
